#include "game.h"

const int inf=1e9;
const double delt=0.95;
const double eps=1e-9;
int ret=inf;

std::vector<int>perm,rans;

void sa(int n){
    double T=1919.81;
    random_shuffle(perm.begin(),perm.end());
    while(T>eps){
        int x=rand()%n,y=rand()%n;
        std::swap(perm[x],perm[y]);
        int k=n-count(perm);
        if(k<ret){
            ret=k;
            if(ret==0){
                rans=perm;
                return ;
            }
        }
        else if(exp(k-ret)/T<=(double)rand()/RAND_MAX) std::swap(perm[x],perm[y]);
        T*=delt;
    }
}

std :: vector<int> guess(int n, int limit) {
	std :: vector<int> ans;
	ans.resize(n);
	for(int i = 1; i <= n; i ++)
		ans[i - 1] = i;

    if(n<=9){
        std::vector<int>p;
        p.resize(n);
        for(int i=1;i<=n;i++) p[i-1]=i;
        do{
            int k=n-count(p);
            if(k==0) return p;
        }while(next_permutation(p.begin(),p.end()));
        // return p;
    }
    else{
        perm.resize(n);
        for(int i=1;i<=n;i++) perm[i-1]=i;
        while(true){
            sa(n);
            if(ret==0) return rans;
        }
    }

	return ans;
}
